home *** CD-ROM | disk | FTP | other *** search
Modula Implementation | 1997-10-26 | 18.3 KB | 568 lines |
- (*----------------------------------------------------------------------*
- * *
- * MAGICTOOLS Modula's All purpose GEM Interface Cadre Toolbox *
- * ÿ ÿ ÿ ÿ ÿ *
- *----------------------------------------------------------------------*
- * Version 3.30 02.02.1992 (C)90/91/92 by Peter Hellinger Software *
- *----------------------------------------------------------------------*
- * Dieses Modul ist urheberrechtlich geschtzt. *
- * *
- * Die Verffentlichung des Quelltextes oder Teilen daraus, sowie die *
- * Verbreitung des bersetzten, nicht gelinkten Codes in schriftlicher, *
- * oder maschinenlesbarer Form, insbesondere in Zeitschriften, Mail- *
- * boxen oder anderen Medien bedarf der ausdrcklichen schriftlichen *
- * Einverstndnisserklrung des Autors. *
- * *
- * Die Verbreitung des Moduls als Teil eines gelinkten Programms ist *
- * fr Lizenznehmer ausdrcklich erlaubt! Der Autor behlt sich das *
- * Recht vor, diese Erlaubnis jederzeit und ohne Angaben von Grnden zu *
- * widerrufen. *
- *----------------------------------------------------------------------*)
-
- IMPLEMENTATION MODULE mtFonts;
-
- (*----------------------------------------------------------------------*
- * Int. Vers | Datum | Name | nderung *
- *-----------+----------+------+----------------------------------------*
- * 3.00 | 18.01.92 | Hp | *
- * 3.01 | 02.02.92 | Hp | Freigabe der FSM-Version. Die Non-FSM *
- * | | | wird hiermit nicht mehr vertrieben! *
- *-----------+----------+------+----------------------------------------*)
-
-
-
- (* IMPLEMENTATION FR >>> Megamax-Modula-2 <<< *)
- (* *)
- (*$R- Range-Checks *)
- (*$S- Stack-Check *)
- (* *)
- (*----------------------------------------------*)
-
-
-
-
-
-
- FROM MagicSys IMPORT Nil, Null, Bit0, Bit1, Bit2, Bit3, Bit4, Bit5, Bit6,
- Bit7, Bit8, Bit9, Bit10, Bit11, Bit12, Bit13, Bit14,
- Bit15, LOC, Byte, ByteSet, sWORD, sINTEGER, sCARDINAL,
- sBITSET, lINTEGER, lCARDINAL, lWORD, lBITSET,
- CastToChar, CastToByte, CastToByteset, CastToInt,
- CastToCard, CastToBitset, CastToWord, CastToLInt,
- CastToLCard, CastToLBitset, CastToLWord, CastToAddr,
- TosVersion, Accessory, Basepage, SysHeader, TosDate;
-
-
-
-
-
-
-
-
- FROM Storage IMPORT ALLOCATE, DEALLOCATE;
-
-
-
-
- FROM SYSTEM IMPORT ADDRESS, ADR, BYTE, TSIZE;
- FROM MagicStrings IMPORT Append, Assign, Length;
- FROM MagicConvert IMPORT IntToStr;
- FROM mtAppl IMPORT VqGdos, VDIHandle, CharHeight, CharWidth;
- FROM MagicAES IMPORT SELECTED, OUTLINED, TOUCHEXIT, HIDETREE,
- SELECTABLE, Exit, DEFAULT, DISABLED;
- FROM MagicFSM IMPORT FSMGdos, FontGdos, NoError, CharNotFound,
- ReadError, OpenError, BadFileformat,
- OutOfMemory, MiscError, FsmInt, FsmFpoint,
- FsmDataFpoint, PtrFsmComponent, FsmComponent,
- InqFacename, InqFExtent, FSMText, KillOutline,
- GetOutline, ScratchFSM, ScratchBitmap, NoScratch,
- SetScratch, ToApplication, ToScreen, SetErrormode,
- SetArbpoints, InqAdvance, InqDeviceinfo,
- SaveFSMCache, LoadFSMCache, FlushFSMCache,
- SetSize, SetSkew, GetFSMAsciitable, GetFSMCachesize,
- EnableBezier, DisableBezier, BezierBuffer,
- Bezier, FilledBezier, BezierQuality;
-
- IMPORT MagicTypes, MagicAES, MagicVDI, MagicDOS, MagicBIOS,
- MagicSys, mtAppl, mtUtils;
-
- (*----------------------------------------------------------------------*)
-
- CONST DefSize = 12;
-
- TYPE FONT = POINTER TO Font;
- Font = RECORD
- name: ARRAY [0..32] OF CHAR; (* Name des Fonts *)
- id: sINTEGER; (* Font-ID *)
- color: sINTEGER; (* Farbindex *)
- rot: sINTEGER; (* Rotationsrichtung *)
- halign: sINTEGER; (* Horizontale Ausrichtung *)
- valign: sINTEGER; (* Vertikale Ausrichtung *)
- chw: sINTEGER; (* Zeichenbreite *)
- chh: sINTEGER; (* Zeichenhhe *)
- boxw: sINTEGER; (* Zellenbreite *)
- boxh: sINTEGER; (* Zellenhhe *)
- effect: sBITSET; (* Texteffekte *)
- min: sINTEGER; (* Minimale Gre des Fonts *)
- max: sINTEGER; (* Maximale Gre des Fonts *)
- point: sINTEGER; (* aktuelle Gre des Fonts *)
- width: sINTEGER; (* Breite bei FSM-Fonts *)
- skew: sINTEGER; (* Neigung bei FSM-Fonts *)
- mono: BOOLEAN; (* TRUE, wenn Monospaced *)
- fsm: BOOLEAN; (* TRUE, wenn FSM-Font *)
- next: FONT; (* Zeiger auf nchsten Font *)
- END;
-
- TYPE FONTLIST = POINTER TO Fontlist;
- Fontlist = RECORD
- fonts: FONT;
- dummy: FONT;
- number: INTEGER;
- END;
-
- (*----------------------------------------------------------------------*)
- (* Die folgenden Deklarationen mssen denen in mtAppl gleichen! *)
- (*----------------------------------------------------------------------*)
-
- CONST cFonts = 0;
- cPhysical = 1;
-
- TYPE WsPtr = POINTER TO WsInfo;
- WsInfo = RECORD
- handle: sINTEGER;
- flags: sBITSET;
- list: FONTLIST;
- next: WsPtr;
- last: WsPtr;
- END;
-
- (*----------------------------------------------------------------------*)
-
- VAR attr: ARRAY [0..9] OF sINTEGER;
- e1, e2: ARRAY [0..7] OF sINTEGER;
- gdos: lCARDINAL;
- errorcode: sINTEGER;
- fontliste: FONTLIST;
- p: WsPtr;
- f, f1: FONT;
-
-
- PROCEDURE GetFont (handle, id: sINTEGER): FONT;
- BEGIN
- p:= mtAppl.Intern (handle);
- IF p # NIL THEN
- IF p^.list # NIL THEN
- f:= p^.list^.fonts;
- WHILE f # NIL DO
- IF id = f^.id THEN RETURN f; END;
- f:= f^.next;
- END; (* WHILE *)
- END;
- END;
- RETURN NIL;
- END GetFont;
-
- PROCEDURE LoadFonts (handle: sINTEGER): sINTEGER;
- VAR i, j, d, c, w, ow, ret: sINTEGER;
- BEGIN
- mtAppl.StoreMouse; mtAppl.MouseBusy;
- errorcode:= 0;
- p:= mtAppl.Intern (handle);
- IF p = NIL THEN
- ret:= ErrWorkstation;
- ELSE
- WITH p^ DO
- IF list # NIL THEN
- ret:= list^.number;
- ELSE
- ALLOCATE (list, TSIZE (Fontlist));
- IF list = NIL THEN
- ret:= ErrLessMem;
- ELSE
- list^.dummy:= NIL;
- list^.fonts:= NIL;
- list^.number:= 0;
- WITH list^ DO
- IF gdos = MagicVDI.NoGdos THEN
- number:= 0;
- ELSE
- number:= MagicVDI.LoadFonts (handle, 0);
- INCL (p^.flags, cFonts);
- END;
- f1:= fonts; i:= 0;
- LOOP
- IF i > number THEN EXIT; END;
- ALLOCATE (f, TSIZE (Font));
- IF f = NIL THEN
- ret:= ErrLessMem; EXIT;
- ELSE
- ret:= p^.list^.number;
- f^.fsm:= FALSE;
- f^.id:= InqFacename (handle, i + 1, f^.name, f^.fsm);
- j:= MagicVDI.SetTextface (handle, f^.id);
- MagicVDI.InqText (handle, attr); (* Aktuelle Parameter holen *)
- f^.color:= attr[1];
- f^.rot:= attr[2];
- f^.halign:= attr[3];
- f^.valign:= attr[4];
- f^.chw:= attr[6];
- f^.chh:= attr[7];
- f^.boxw:= attr[8];
- f^.boxh:= attr[9];
- IF f^.fsm THEN
- f^.min:= 1; f^.max:= MAX (sINTEGER);
- ELSE
- f^.min:= MagicVDI.SetCharpoints (handle, 1, j, j, j, j);
- f^.max:= MagicVDI.SetCharpoints (handle, 9999, j, j, j, j);
- END;
- f^.point:= MagicVDI.SetCharpoints (handle, DefSize, j, j, j, j);
- IF f^.id = 1 THEN (* Sonderbehandlung fr Systemfont *)
- Assign ('Systemfont', f^.name); (* Name des Fonts *)
- IF CharHeight = 8 THEN f^.point:= 9; ELSE f^.point:= 10; END;
- END;
- f^.skew:= 0;
- f^.width:= f^.point;
- f^.effect:= {};
- (* Annahme, aber leider gibts keine Abfragemglichkeit *)
- MagicVDI.InqTextextent (handle, 'MMmmWWww', e1);
- MagicVDI.InqTextextent (handle, 'IIiiLLll', e2);
- j:= 0; f^.mono:= TRUE;
- WHILE (j < 8) AND f^.mono DO
- f^.mono:= e1[j] = e2[j]; INC (j);
- END;
- f^.next:= NIL;
- IF f1 # NIL THEN f1^.next:= f; ELSE fonts:= f; END;
- f1:= f;
- END; (* IF f = NIL *)
- INC (i);
- END; (* LOOP *)
- (* Systemfont wieder einstellen *)
- j:= MagicVDI.SetTextface (handle, 1);
- IF CharHeight = 8 THEN i:= 9; ELSE i:= 10; END;
- j:= MagicVDI.SetCharpoints (handle, i, j, j, j, j);
- END; (* WITH list *)
- END; (* IF list = NIL *)
- END; (* IF list # NIL*)
- END; (* WITH p *)
- END; (* IF p = NIL *)
- mtAppl.RestoreMouse;
- RETURN ret;
- END LoadFonts;
-
- PROCEDURE UnloadFonts (handle: sINTEGER);
- BEGIN
- errorcode:= 0;
- p:= mtAppl.Intern (handle);
- IF p # NIL THEN
- IF p^.list # NIL THEN
- f:= p^.list^.fonts; f1:= f;
- WHILE f # NIL DO
- DEALLOCATE (f, 0); ; f:= f1^.next; f1:= f;
- END; (* WHILE *)
- DEALLOCATE (p^.list, 0); ;
- END; (* IF p^.list *)
- EXCL (p^.flags, cFonts);
- END; (* IF p # NIL *)
- MagicVDI.UnloadFonts (handle, 0);
- END UnloadFonts;
-
- PROCEDURE FontList (handle, flag: sINTEGER): sINTEGER;
- VAR x, x2: FONT;
- BEGIN
- errorcode:= 0;
- p:= mtAppl.Intern (handle);
- IF p # NIL THEN
- IF p^.list # NIL THEN
- x:= NIL;
- IF p^.list^.dummy = NIL THEN p^.list^.dummy:= p^.list^.fonts; END;
- CASE flag OF
- FFIRST: x:= p^.list^.fonts;
- |
- FNEXT: p^.list^.dummy:= p^.list^.dummy^.next;
- x:= p^.list^.dummy;
- |
- FPREV: x:= p^.list^.fonts;
- WHILE (x # NIL) AND (x^.next # p^.list^.dummy) DO
- x:= x^.next;
- END;
- IF x # NIL THEN p^.list^.dummy:= x; END;
- |
- FLAST: x2:= p^.list^.fonts;
- WHILE (x2 # NIL) DO x:= x2; x2:= x2^.next; END;
- IF x # NIL THEN p^.list^.dummy:= x; END;
- |
- ELSE ;
- END; (* CASE *)
- END; (* IF p^.list *)
- END; (* IF p # NIL *)
- IF x = NIL THEN RETURN 0; ELSE RETURN x^.id; END;
- END FontList;
-
- PROCEDURE FontInfo (handle, font: sINTEGER; VAR info: tFontinfo);
- BEGIN
- errorcode:= 0;
- f:= GetFont (handle, font);
- IF f # NIL THEN
- Assign (f^.name, info.name);
- info.id:= f^.id;
- info.color:= f^.color;
- info.rot:= f^.rot;
- info.halign:= f^.halign;
- info.valign:= f^.valign;
- info.chw:= f^.chw;
- info.chh:= f^.chh;
- info.boxw:= f^.boxw;
- info.boxh:= f^.boxh;
- info.effect:= f^.effect;
- info.min:= f^.min;
- info.max:= f^.max;
- info.point:= f^.point;
- info.width:= f^.width;
- info.skew:= f^.skew;
- info.mono:= f^.mono;
- info.fsm:= f^.fsm;
- ELSE (* Keine Fonts geladen *)
- MagicVDI.InqText (handle, attr);
- info.id:= attr[0];
- IF info.id = 1 THEN Assign ('Systemfont', info.name);
- ELSE Assign ('', info.name);
- END;
- info.color:= attr[1];
- info.rot:= attr[2];
- info.halign:= attr[3];
- info.valign:= attr[4];
- info.chw:= attr[6];
- info.chh:= attr[7];
- info.boxw:= attr[8];
- info.boxh:= attr[9];
- info.min:= -1;
- info.max:= -1;
- info.width:= -1;
- info.skew:= -1;
- info.fsm:= FALSE;
- IF info.id = 1 THEN
- IF CharHeight = 8 THEN info.point:= 9; ELSE info.point:= 10; END;
- END;
- info.mono:= TRUE;
- END; (* IF list *)
- END FontInfo;
-
- PROCEDURE FontActive (handle: sINTEGER): sINTEGER;
- BEGIN
- errorcode:= 0;
- MagicVDI.InqText (handle, attr);
- f:= GetFont (handle, attr[0]);
- IF f # NIL THEN (* Bei der Gelgenheit gleichmal unsere Daten auffrischen *)
- f^.color:= attr[1];
- f^.rot:= attr[2];
- f^.halign:= attr[3];
- f^.valign:= attr[4];
- f^.chw:= attr[6];
- f^.chh:= attr[7];
- f^.boxw:= attr[8];
- f^.boxh:= attr[9];
- END;
- RETURN attr[0];
- END FontActive;
-
- PROCEDURE FontSelect (handle: sINTEGER; font: sINTEGER; actual: BOOLEAN);
- VAR i, p, w, s, r, c: sINTEGER; e: sBITSET;
- BEGIN
- errorcode:= 0;
- IF actual THEN f:= GetFont (handle, FontActive (handle));
- ELSE f:= GetFont (handle, font);
- END;
- IF f # NIL THEN
- p:= f^.point; w:= f^.width; s:= f^.skew;
- r:= f^.rot; c:= f^.color; e:= f^.effect;
- IF actual THEN f:= GetFont (handle, font); END;
- IF f # NIL THEN
- i:= MagicVDI.SetTextface (handle, font);
- IF f^.fsm THEN
- f^.point:= SetArbpoints (handle, p, i, i, i, i);
- f^.width:= SetSize (handle, w, i, i, i, i);
- f^.skew:= SetSkew (handle, s);
- ELSE
- f^.point:= MagicVDI.SetCharpoints (handle, p, i, i, i, i);
- END;
- f^.rot:= MagicVDI.SetCharbaseline (handle, r);
- f^.color:= MagicVDI.SetTextcolor (handle, c);
- f^.effect:= MagicVDI.SetTexteffect (handle, e);
- ELSE
- errorcode:= -1;
- END;
- i:= FontActive (handle);
- ELSE
- errorcode:= -1;
- END;
- END FontSelect;
-
- PROCEDURE FontSize (handle: sINTEGER; point: sINTEGER;
- VAR chw, chh, boxw, boxh: sINTEGER): sINTEGER;
- VAR i: sINTEGER;
- BEGIN
- errorcode:= 0;
- f:= GetFont (handle, FontActive (handle));
- IF f # NIL THEN
- IF f^.fsm THEN
- f^.point:= SetArbpoints (handle, point, chw, chh, boxw, boxh);
- f^.width:= SetSize (handle, f^.width, i, i, i, i);
- f^.skew:= SetSkew (handle, f^.skew);
- ELSE
- f^.point:= MagicVDI.SetCharpoints (handle, point, chw, chh, boxw, boxh);
- END;
- i:= FontActive (handle);
- RETURN f^.point;
- ELSE
- errorcode:= -1;
- END;
- RETURN errorcode;
- END FontSize;
-
- PROCEDURE FontDefsize (handle: INTEGER): INTEGER;
- VAR i, j: sINTEGER;
- BEGIN
- errorcode:= 0;
- f:= GetFont (handle, FontActive (handle));
- IF f # NIL THEN
- IF f^.id = 1 THEN
- IF CharHeight = 8 THEN i:= 9; ELSE i:= 10; END;
- ELSIF f^.fsm THEN
- i:= DefSize;
- ELSE
- i:= f^.max DIV 2;
- END;
- f^.point:= MagicVDI.SetCharpoints (handle, i, j, j, j, j);
- i:= FontActive (handle);
- RETURN f^.point;
- ELSE
- errorcode:= -1;
- END;
- RETURN errorcode;
- END FontDefsize;
-
- PROCEDURE NextSize (handle: INTEGER; bigger: BOOLEAN): INTEGER;
- VAR act, size, new, i: INTEGER;
- ende: BOOLEAN;
- BEGIN
- errorcode:= 0;
- f:= GetFont (handle, FontActive (handle));
- IF f # NIL THEN
- new:= f^.point; act:= f^.point;
- IF bigger THEN ende:= f^.point >= f^.max;
- ELSE ende:= f^.point <= f^.min;
- END;
- WHILE (f^.point = act) AND (NOT ende) DO
- IF bigger THEN INC (new); ende:= f^.point >= f^.max;
- ELSE DEC (new); ende:= f^.point <= f^.min;
- END;
- IF f^.fsm THEN
- f^.point:= SetArbpoints (handle, new, i, i, i, i);
- f^.width:= SetSize (handle, f^.width, i, i, i, i);
- f^.skew:= SetSkew (handle, f^.skew);
- ELSE
- f^.point:= MagicVDI.SetCharpoints (handle, new, i, i, i, i);
- END;
- END;
- i:= FontActive (handle);
- RETURN f^.point;
- ELSE
- errorcode:= -1;
- END;
- RETURN errorcode;
- END NextSize;
-
- PROCEDURE NextBigger (handle: INTEGER): INTEGER;
- BEGIN
- RETURN NextSize (handle, TRUE);
- END NextBigger;
-
- PROCEDURE NextSmaller (handle: INTEGER): INTEGER;
- BEGIN
- RETURN NextSize (handle, FALSE);
- END NextSmaller;
-
- PROCEDURE FontColor (handle, color: sINTEGER);
- BEGIN
- errorcode:= 0;
- f:= GetFont (handle, FontActive (handle));
- IF f # NIL THEN
- f^.color:= MagicVDI.SetTextcolor (handle, color);
- ELSE
- errorcode:= -1;
- END;
- END FontColor;
-
- PROCEDURE FontEffekt (handle: sINTEGER; effekt: sBITSET);
- BEGIN
- errorcode:= 0;
- f:= GetFont (handle, FontActive (handle));
- IF f # NIL THEN
- f^.effect:= MagicVDI.SetTexteffect (handle, effekt);
- ELSE
- errorcode:= -1;
- END;
- END FontEffekt;
-
- PROCEDURE FontRotate (handle, angle: sINTEGER): sINTEGER;
- BEGIN
- errorcode:= 0;
- f:= GetFont (handle, FontActive (handle));
- IF f # NIL THEN
- f^.rot:= MagicVDI.SetCharbaseline (handle, angle);
- RETURN f^.rot;
- ELSE
- errorcode:= -1;
- END;
- RETURN errorcode;
- END FontRotate;
-
- PROCEDURE FontWidth (handle, width: sINTEGER);
- VAR i: sINTEGER;
- BEGIN
- errorcode:= 0;
- f:= GetFont (handle, FontActive (handle));
- IF f # NIL THEN
- IF f^.fsm THEN f^.width:= SetSize (handle, width, i, i, i, i); END;
- ELSE
- errorcode:= -1;
- END;
- END FontWidth;
-
- PROCEDURE FontSkew (handle: sINTEGER; skew: sINTEGER);
- BEGIN
- errorcode:= 0;
- f:= GetFont (handle, FontActive (handle));
- IF f # NIL THEN
- IF f^.fsm THEN f^.skew:= SetSkew (handle, skew); END;
- ELSE
- errorcode:= -1;
- END;
- END FontSkew;
-
- PROCEDURE FontExtent (handle: sINTEGER; REF str: ARRAY OF CHAR;
- VAR rect: ARRAY OF LOC);
- BEGIN
- errorcode:= 0;
- f:= GetFont (handle, FontActive (handle));
- IF f # NIL THEN
- IF f^.fsm THEN InqFExtent (handle, str, rect);
- ELSE MagicVDI.InqTextextent (handle, str, rect)
- END;
- ELSE
- errorcode:= -1;
- END;
- END FontExtent;
-
- PROCEDURE FontError (): sINTEGER;
- BEGIN
- RETURN errorcode;
- END FontError;
-
- BEGIN
- gdos:= VqGdos();
- IF gdos = FSMGdos THEN
- SetErrormode (VDIHandle, ToApplication, errorcode);
- END;
- END mtFonts.
-